#include <iostream>
#include <vector>

using namespace std;

const int N = 1e4 + 10;
int n, m, w;
int c[N], d[N];
int un_c[N], un_d[N], pos;
int f[N];
bool st[N];
vector<int> edges[N];

void dfs(int root)
{
	st[root] = true;
	un_c[pos] += c[root];
	un_d[pos] += d[root];
	for (auto x : edges[root])
	{
		if (!st[x]) dfs(x);
	}
}

int main()
{
	cin >> n >> m >> w;
	for (int i = 1; i <= n; i++)
	{
		cin >> c[i] >> d[i];
	}

	for (int i = 1; i <= m; i++)
	{
		int x, y; cin >> x >> y;
		edges[x].push_back(y);
		edges[y].push_back(x);
	}

	for (int i = 1; i <= n; i++)
	{
		if (!st[i])
		{
			pos++;
			dfs(i);
		}
	}

	for (int i = 1; i <= pos; i++)
		for (int j = w; j >= un_c[i]; j--)
			f[j] = max(f[j], f[j - un_c[i]] + un_d[i]);

	cout << f[w] << endl;
	return 0;
}
